package com.yyzw.activiti.modeler.service.impl;

import com.yyzw.activiti.modeler.dao.MenuMapper;
import com.yyzw.activiti.modeler.model.SysMenu;
import com.yyzw.activiti.modeler.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class MenuServiceImpl implements MenuService {

    @Autowired
    MenuMapper menuMapper;

    @Override
    public List<SysMenu> getAdminMenu() {
        return this.menuMapper.selectAll();
    }

    @Override
    public List<SysMenu> getUserMenuByRoleId(int roleId) {
        return this.menuMapper.getUserMenuByRoleId(roleId);
    }

    @Override
    public List<SysMenu> getMenuNodeByPid(int menuId) {
        Example example =new Example(SysMenu.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("parentId",menuId);
        List<SysMenu> sysMenus = this.menuMapper.selectByExample(example);
        return sysMenus;
    }
}
